<?php

App::uses('AppController', 'Controller');
App::uses('Set', 'Util');

class BrandsController extends AppController {
    
    public $uses = array('Brand', 'BrandModel');
    
    public $title = 'Modeli';
    
    public function search($keyword, $object) {
        $this->layout = 'ajax';
        $func         = 'SelectBrand';
        
        $data = $this->Brand->find('all', array(
            'fields' => array('Brand.id', 'Brand.name'),
            'conditions' => array(
                'Brand.name LIKE' => "%" . $keyword . "%"
            ),
            'order' => 'Brand.name',
            'limit' => 10
        ));
        if (! empty($data)) {
            $data = Set::extract('{n}.Brand', $data);
        } else {
            header('Status: 1');
        }
        
        $this->set(compact('data', 'func', 'object'));
        $this->render('/Elements/dropdown');
    }

}

?>